package csel.controller.decoders;

import csel.controller.dispatchers.AbstractDispatcher;
import csel.controller.factories.CommandFactory;
import csel.controller.factories.ModelCommandFactory;
import csel.controller.factories.ViewCommandFactory;
import csel.controller.listeners.StatusViewActionListener;

/**
 * Reasons for Existence: Decodes actions in the status view, 
 * selects a dispatcher and command factory</br>
 * Team Members Responsible</br>
 * Implementation: Nik, Tait</br>
 * Testing: Nik, Tait</br> 
 * 
 * @author Nikolas Wolfe
 */
public class StatusActionEventDecoder extends AbstractActionEventDecoder
{
	//constructor
	public StatusActionEventDecoder(StatusViewActionListener listener,
			AbstractDispatcher modelDispatcher,
			AbstractDispatcher viewDispatcher,
			ModelCommandFactory modelCommandFactory,
			ViewCommandFactory viewCommandFactory)
	{
		this.listener = listener;
		this.modelDispatcher = modelDispatcher;
		this.viewDispatcher = viewDispatcher;
		this.modelCommandFactory = modelCommandFactory;
		this.viewCommandFactory = viewCommandFactory;
	}
	
	//overrides superclass and determines what command is needed and sets the creation in motion
	@Override
	public void parseCommand()
	{
		String cmd = actionEvent.getActionCommand();
		if (cmd == "stdrop")
		{
			System.out.println("[CONTROLLER] The drop command was parsed");
			this.setToModel();
			modelCommandFactory.newDropCommandFactory();
		} else if (cmd == "stuse")
		{
			System.out.println("[CONTROLLER] The use command was parsed");
			this.setToModel();
			modelCommandFactory.newUseCommandFactory();
		} else if (cmd == "stequip")
		{
			System.out.println("[CONTROLLER] The equip command was parsed");
			this.setToModel();
			modelCommandFactory.newEquipCommandFactory();
		} else if (cmd == "stunequip")
		{
			System.out.println("[CONTROLLER] The unequip command was parsed");
			this.setToModel();
			modelCommandFactory.newUnequipCommandFactory();
		} else if (cmd == "stquit")
		{
			System.out.println("[CONTROLLER] The quit command was parsed");
			this.setToModel();
			modelCommandFactory.newQuitCommandFactory();
		} else if (cmd == "stsave")
		{
			System.out.println("[CONTROLLER] The save command was parsed");
			this.setToModel();
			modelCommandFactory.newSaveCommandFactory();
		} else if (cmd == "stload")
		{
			System.out.println("[CONTROLLER] The load command was parsed");
			this.setToModel();
			modelCommandFactory.newLoadCommandFactory();
		} else if (cmd == "stnew")
		{
			System.out.println("[CONTROLLER] The new command was parsed");
			this.setToModel();
			modelCommandFactory.newNewCommandFactory();
		} else
		{
			System.out
					.println("[CONTROLLER] " + cmd + " is not a valid command");
		}
	}
}
